package com.wntms.ft.service.impl;

import com.github.pagehelper.PageHelper;
import com.wntms.ft.dao.BillDao;
import com.wntms.ft.pojo.CarriageContract;
import com.wntms.ft.pojo.CustomerBill;
import com.wntms.ft.pojo.DriverBill;
import com.wntms.ft.pojo.FreightContractBill;
import com.wntms.ft.service.BillService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class BillServiceImpl implements BillService {
    @Autowired
    private BillDao billDao;

    /**
     * 查询所有用户回执单
     * @param pageNum
     * @param pageSize
     * @return
     */
    @Override
    public List<CustomerBill> findAllCustomer(int pageNum,int pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<CustomerBill> allCustomer = billDao.findAllCustomer();
        return allCustomer;
    }

    /**
     * 根据用户fid删除一条记录
     * @param number
     * @return
     */
    @Override
    public int deleteByCustomerId(String number) {
        int i = billDao.deleteCustomer(number);
        return i;
    }
    /**
     * 查询所有司机回执单
     */
    @Override
    public List<DriverBill> findAllDriver(int pageNum, int pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<DriverBill> allCustomer = billDao.findAllDriver();
        return allCustomer;
    }

    /**
     * 根据id删除司机回执单
     * @param number
     * @return
     */
    @Override
    public int deleteByDriverId(int number) {
        int i = billDao.deleteDriver(number);
        return i;
    }


    /**
     * 查询货运单合同表
     * @return
     */
    @Override
    public List<FreightContractBill> findAllFreightBill(int pageNum, int pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<FreightContractBill> allFreightBill = billDao.findAllFreightBill();
        return allFreightBill;
    }

    @Override
    public int deleteByFreightId(int number) {
        int i = billDao.deleteByFreightId(number);
        return i;
    }

    @Override
    public List<CarriageContract> findAllCarriageBill(int pageNum, int pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<CarriageContract> allCarriageBill = billDao.findAllCarriageBill();
        return allCarriageBill;
    }

    @Override
    public int deleteByCarriageId(String number) {
        int i = billDao.deleteByCarriageId(number);
        System.out.println(number);
        return i;
    }
}
